package itherit;

//一般情况  继承不要超过三层
class Amimal{
    private String name;
    public int age;

    public void eat(){
        System.out.println(name+"正在吃饭");
    }

    public void sleep(){
        System.out.println(name+"正在睡觉");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}



class Dog extends Amimal{
    /*public String name;
    public int age;

    public void eat(){
        System.out.println(name+"正在吃饭");
    }*/
    public void barks(){
        System.out.println(getName()+"正在汪汪叫"+" age:"+age);
    }

}

class Cat extends Amimal{
    /*public String name;
    public int age;

    public void eat() {
        System.out.println(name + "正在吃饭");
    }*/

    public void catchMouse(){
            System.out.println("age:"+age+" "+getName()+"正在抓老鼠");
        }


}

class A extends Dog{

}

public class Test {
    public static void main(String[] args) {
        Dog dog  =new Dog();
        dog.age = 18;
dog.setName("小黄");
        System.out.println(dog.getName());
        dog.eat();
        dog.barks();
    }

}
